
package com.idealighter.game.games.errentexaspoker.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.errentexaspoker.dto.RoomInfo;
import com.idealighter.game.games.errentexaspoker.dto.RoomTypeDetailInfo;
import com.idealighter.game.games.errentexaspoker.message.ResGameHallMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.common.PlayerPosition;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;

import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@ResMsgHandler(515201)
public class ResGameHallHandler implements ResMessageHandler {
  private static final Logger LOG = LoggerFactory.getLogger(ResGameHallHandler.class);

  @Override
  public void action(Player player, ResMessage message) {

    LOG.info("[二人德州扑克]玩家[{}][{}]进入大厅成功", player.userName, player.playerId);
    Set<Integer> rooms = player.rooms;
    player.position = PlayerPosition.HALL;

    rooms.clear();

    ResGameHallMsg msg = (ResGameHallMsg) message;

    for (RoomTypeDetailInfo roomTypeDetailInfo : msg.getRoomTypes()) {
      for (RoomInfo roomInfo : roomTypeDetailInfo.getRooms()) {
        rooms.add(roomInfo.getRoomId());
      }
    }

    player.enterRoom();
  }
}
